﻿using System.ServiceModel;
using System;
using sscore;

namespace DM4
{
    [ServiceContract]
    public interface IDM4
    {
        [OperationContract]
        GlobalInfo GetInfo();

        [OperationContract]
        XMLInfo Login(string user, string password);

        [OperationContract]
        XMLInfo GetUserList(string usrSessionId);

        [OperationContract]
        XMLInfo GetModulesList(int grpId = DM4Consts.DefaultNULLId);

        [OperationContract]
        XMLInfo GetModuleHelp(string moduleCode);

        //-----------Groups------------------------------
        [OperationContract]
        XMLInfo GetGroupList(string usrSessionId, bool showall = false);

        [OperationContract]
        OperationResult AddGroup(string usrSessionId, bool publicGroup, string name, string description, string homedir, int scriptId);

        [OperationContract]
        OperationResult EditGroup(string usrSessionId, int grpId, string name, string description, string homedir, int scriptId);

        [OperationContract]
        OperationResult DeleteGroup(string usrSessionId, int grpId);

        //------------Scripts-----------------------------
        [OperationContract]
        XMLInfo GetScriptList(string usrSessionId);

        [OperationContract]
        OperationResult AddScript(string usrSessionId, string name, string description, string text);

        [OperationContract]
        OperationResult EditScript(string usrSessionId, int scriptId, string name, string description, string text);

        [OperationContract]
        OperationResult DeleteScript(string usrSessionId, int scriptId);

        [OperationContract]
        OperationResult RunScript(string usrSessionId, int rchId = DM4Consts.DefaultNULLId, string rshSessionId = null, string[] modCode = null, string modParams = null);        

        //-------------MailSendTemplates----------------------------
        [OperationContract]
        XMLInfo GetMailSendTemplateList(string usrSessionId);

        [OperationContract]
        OperationResult AddMailSendTemplate(string usrSessionId, string name, string subject, string body);

        [OperationContract]
        OperationResult EditMailSendTemplate(string usrSessionId, int templateId, string name, string subject, string body);

        [OperationContract]
        OperationResult DeleteMailSendTemplate(string usrSessionId, int templateId);

        //-------------MailAccounts----------------------------
        [OperationContract]
        XMLInfo GetMailAccountList(string usrSessionId);

        [OperationContract]
        OperationResult AddMailAccount(string usrSessionId, string mail, string sendServer, string sendPort, string sendUser, string sendPassword, bool sendUseSsl
            , string receiveServer, string receivePort, string receiveUser, string receivePassword, bool receiveUseSsl);

        [OperationContract]
        OperationResult EditMailAccount(string usrSessionId, int accountId, string mail, string sendServer, string sendPort, string sendUser, string sendPassword, bool sendUseSsl
            , string receiveServer, string receivePort, string receiveUser, string receivePassword, bool receiveUseSsl);

        [OperationContract]
        OperationResult DeleteMailAccount(string usrSessionId, int accountId);

        //-------------MailSenders----------------------------
        [OperationContract]
        XMLInfo GetMailSendersList(string usrSessionId);

        [OperationContract]
        OperationResult AddMailSender(string usrSessionId, string mail);

        [OperationContract]
        OperationResult EditMailSender(string usrSessionId, int id, string mail);

        [OperationContract]
        OperationResult DeleteMailSender(string usrSessionId, int id);

        //-------------Letters----------------------------
        [OperationContract]
        XMLInfo GetLettersList(string usrSessionId, string expression = "");

        [OperationContract]
        OperationResult AddLetter(string usrSessionId, int senderId, string description);

        [OperationContract]
        OperationResult EditLetter(string usrSessionId, int id, int senderId, string description);

        [OperationContract]
        OperationResult DeleteLetter(string usrSessionId, int id);

        //-------------Mail Rules----------------------------
        [OperationContract]
        XMLInfo GetMailRulesList(string usrSessionId, string expression = "");

        [OperationContract]
        OperationResult AddMailRule(string usrSessionId, string ruleName, string rule, MailRuleType mrt);

        [OperationContract]
        OperationResult EditMailRule(string usrSessionId, int id, string ruleName, string rule, MailRuleType mrt);

        [OperationContract]
        OperationResult DeleteMailRule(string usrSessionId, int id);

        //-------------MailLettersRules----------------------------
        [OperationContract]
        XMLInfo GetMailLettersRulesList(string usrSessionId, int letterId);

        [OperationContract]
        OperationResult AddMailLettersRule(string usrSessionId, int letterId, int ruleId);

        //[OperationContract]
        //OperationResult EditMailLettersRule(string usrSessionId, int id, int letterId, int ruleId);

        [OperationContract]
        OperationResult DeleteMailLettersRule(string usrSessionId, int letterId, int ruleId, int id = DM4Consts.DefaultNULLId);

        //work
        [OperationContract]
        XMLInfo GetWorkTree(string usrSessionId, bool showall = false);

        #region Session function
        [OperationContract]
        XMLInfo GetSessionsList(string usrSessionId);

        [OperationContract]
        OperationResult AbortSession(string usrSessionId, string sessionId);

        [OperationContract]
        OperationResult ResumeSession(string usrSessionId, string sessionId);

        [OperationContract]
        OperationResult AbortTask(string usrSessionId, string taskId);

        [OperationContract]
        OperationResult ResumeTask(string usrSessionId, string taskId);

        [OperationContract]
        OperationResult AbortScript(string usrSessionId, string ScriptId);

        [OperationContract]
        OperationResult ResumeScript(string usrSessionId, string ScriptId);
        #endregion

    }
}
